<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ChangeExpectIncomeToWaimai extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 分表库
        for ($i = 0; $i <= 99; $i++) {
            $this->name = '_' . str_pad($i, 3, 0, STR_PAD_LEFT);
            Schema::connection("mysqlWaiMai")->table('waimai_orders' . $this->name, function (Blueprint $table) {
                $table->integer('expectIncome')->change();
                $table->integer('discountPrice')->change();
            });

            Schema::connection("mysqlWaiMai")->table('waimai_order_details' . $this->name, function (Blueprint $table) {
                $table->integer('incomes')->change();
                $table->integer('discountPrice')->change();
            });
        }
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // 分表库
        for ($i = 0; $i <= 99; $i++) {
            $this->name = '_' . str_pad($i, 3, 0, STR_PAD_LEFT);
            Schema::connection("mysqlWaiMai")->table('waimai_orders' . $this->name, function (Blueprint $table) {
                $table->unsignedInteger('expectIncome')->change();
                $table->unsignedInteger('discountPrice')->change();
            });

            Schema::connection("mysqlWaiMai")->table('waimai_order_details' . $this->name, function (Blueprint $table) {
                $table->unsignedInteger('incomes')->change();
                $table->unsignedInteger('discountPrice')->change();
            });
        }
    }
}
